package com.lanou.utp.controller;

import com.lanou.utp.entity.School;
import com.lanou.utp.service.SchoolService;
import com.lanou.utp.entity.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author MaQingYun
 */
@Api("学校")
@RestController
public class SchoolController {

    @Resource
    private SchoolService schoolService;

    @ApiOperation("查询学校相关的信息")
    @GetMapping("/school/7")
    public ResponseData getSchool(){
        School school = this.schoolService.getSchool();
        return new ResponseData(school);
    }

    @ApiOperation("更新学校信息")
    @PutMapping("/school/7")
    public ResponseData updateSchoolInfo(@RequestBody @Validated(School.update.class) School school){
        this.schoolService.updateSchoolInfo(school);
        return new ResponseData("ok");
    }


}
